package com.trkj.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.trkj.dao.HouseExpenseDao;
import com.trkj.entity.HouseExpenseEntity;
import com.trkj.entity.ZongEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class HouseExpenseImpl implements HouseExpenseService{
    @Autowired
    private HouseExpenseDao dao;
    @Override
    @Cacheable(cacheNames = "allusers",key = "#currentPage+','+#pageSize")
    public PageInfo<HouseExpenseEntity> selectAll(HouseExpenseEntity HouseExpenseEntity , int currentPage, int pageSize){
        PageHelper.startPage(currentPage,pageSize);
        List<HouseExpenseEntity> List= this.dao.selectAll(HouseExpenseEntity);
        PageInfo<HouseExpenseEntity> pageDto=new PageInfo<>(List);
        log.debug("123:{}",pageDto);
        return pageDto;
    }

    @Override
    public List<HouseExpenseEntity> findItem() {
        return dao.findItem();
    }


    @Override
    @Cacheable(cacheNames = "allusers",key = "#currentPage+','+#pageSize")
    public PageInfo<HouseExpenseEntity> findAllEx(HouseExpenseEntity houseExpenseEntity,int currentPage, int pageSize) {
        PageHelper.startPage(currentPage,pageSize);
        List<HouseExpenseEntity> List= this.dao.findAllEx(houseExpenseEntity);
        PageInfo<HouseExpenseEntity> pageDto=new PageInfo<>(List);
        log.debug("123:{}",pageDto);
        return pageDto;
    }

    @Override
    public List<ZongEntity> findAll() {
        return dao.findAll();
    }

}
